package com.cm367.teamc.message;

import java.util.Date;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import com.cm367.teamc.session.Language;
import com.cm367.teamc.util.DateUtil;

@ManagedBean
public class EMessage {

	@ManagedProperty(value = "#{language}")
	private Language language;

	public Language getLanguage() {
		return language;
	}

	public void setLanguage(Language language) {
		this.language = language;
	}

	private String getLang() {
		return language.getLocale().getDisplayLanguage();
	}

	public String getDeleteUser() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u5220\u9664\u8FD9\u4E2A\u7528\u6237\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u522A\u9664\u9019\u500B\u7528\u6236\u55CE\uFF1F";
		} else {
			return "Really want to delete the user?";
		}
	}

	public String getDeleteHoliday() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u5220\u9664\u8FD9\u4E2A\u5047\u671F\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u522A\u9664\u9019\u500B\u5047\u671F\u55CE\uFF1F";
		} else {
			return "Really want to delete the holiday?";
		}
	}

	public String getDeleteType() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u5220\u9664\u8FD9\u4E2A\u7C7B\u578B\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u522A\u9664\u9019\u500B\u985E\u578B\u55CE\uFF1F";
		} else {
			return "Really want to delete the type?";
		}
	}

	public String existUserID(String userID) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u7528\u6237\u8D26\u53F7'" + userID
					+ "'\u5DF2\u7ECF\u5B58\u5728\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u7528\u6236\u8CEC\u865F'" + userID
					+ "'\u5DF2\u7D93\u5B58\u5728\u3002";
		} else {
			return "This user ID '" + userID + "' already is exist.";
		}
	}

	public String createSuccess(String userID) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u7528\u6237\u8D26\u53F7'" + userID
					+ "'\u6DFB\u52A0\u6210\u529F\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u7528\u6236\u8CEC\u865F'" + userID
					+ "'\u65B0\u589E\u6210\u529F\u3002";
		} else {
			return "This user '" + userID + "' has been created successfully.";
		}
	}

	public String addManagerFirst() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u6DFB\u52A0\u5931\u8D25\uFF0C\u8BF7\u5148\u6DFB\u52A0Manager\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u65B0\u589E\u5931\u6557\uFF0C\u8ACB\u5148\u65B0\u589EManager\u3002";
		} else {
			return "Create failed. Please add the manager first.";
		}
	}

	public String tryLater() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u6DFB\u52A0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u65B0\u589E\u5931\u6557\uFF0C\u8ACB\u7A0D\u5F8C\u518D\u8A66\u3002";
		} else {
			return "Create failed. Please try later.";
		}
	}

	public String existManager() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u6DFB\u52A0\u5931\u8D25\uFF0C\u8BE5\u90E8\u95E8Manager\u5DF2\u7ECF\u5B58\u5728\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u65B0\u589E\u5931\u6557\uFF0C\u8A72\u90E8\u9580Manager\u5DF2\u7D93\u5B58\u5728\u3002";
		} else {
			return "Create failed. The manager is already exist in the department.";
		}
	}

	public String holidaySuccess(Date date) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u516C\u5171\u5047\u671F'" + DateUtil.getStringDate(date)
					+ "'\u6DFB\u52A0\u6210\u529F\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u516C\u8846\u5047\u671F'" + DateUtil.getStringDate(date)
					+ "'\u65B0\u589E\u6210\u529F\u3002";
		} else {
			return "Public Holiday '" + DateUtil.getStringDate(date)
					+ "' has been added.";
		}
	}

	public String holidayFail(Date date) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u516C\u5171\u5047\u671F'" + DateUtil.getStringDate(date)
					+ "'\u6DFB\u52A0\u5931\u8D25\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u516C\u8846\u5047\u671F'" + DateUtil.getStringDate(date)
					+ "'\u65B0\u589E\u5931\u6557\u3002";
		} else {
			return "Create public holiday " + DateUtil.getStringDate(date)
					+ "failed";
		}
	}

	public String getType(String leaveType) {
		String lang = getLang();
		if (leaveType.equals("AL")) {
			if (lang.equals("zh_cn")) {
				return "\u5E74\u5047";
			} else if (lang.equals("zh_tw")) {
				return "\u5E74\u5047";
			} else {
				return leaveType;
			}
		} else {
			if (lang.equals("zh_cn")) {
				return "\u75C5\u5047";
			} else if (lang.equals("zh_tw")) {
				return "\u75C5\u5047";
			} else {
				return leaveType;
			}
		}
	}

	public String typeSuccess(String leaveType, int days) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "'" + getType(leaveType) + "'\u5DF2\u8BBE\u7F6E\u4E3A"
					+ days + "\u5929\u3002";
		} else if (lang.equals("zh_tw")) {
			return "'" + getType(leaveType) + "'\u5DF2\u8A2D\u7F6E\u70BA"
					+ days + "\u5929\u3002";
		} else {
			return "'" + getType(leaveType) + "' has been set to '" + days
					+ "' days.";
		}
	}

	public String typeFail(String leaveType) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "'" + getType(leaveType) + "'\u8BBE\u7F6E\u5931\u8D25\u3002";
		} else if (lang.equals("zh_tw")) {
			return "'" + getType(leaveType) + "'\u8A2D\u7F6E\u5931\u6557\u3002";
		} else {
			return "Create rule " + getType(leaveType) + "failed.";
		}
	}

	public String getApprove() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u540C\u610F";
		} else if (lang.equals("zh_tw")) {
			return "\u540C\u610F";
		} else {
			return "Approve";
		}
	}

	public String getReject() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u62D2\u7EDD";
		} else if (lang.equals("zh_tw")) {
			return "\u62D2\u7D55";
		} else {
			return "Reject";
		}
	}

	public String app() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u540C\u610F\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u540C\u610F\u55CE\uFF1F";
		} else {
			return "Really want to approve?";
		}
	}

	public String rej() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u62D2\u7EDD\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u62D2\u7D55\u55CE\uFF1F";
		} else {
			return "Really want to reject?";
		}
	}

	public String typeLeft(String type, int day) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "'" + getType(type) + "'\u5269\u4F59" + day + "\u5929\u3002";
		} else if (lang.equals("zh_tw")) {
			return "'" + getType(type) + "'\u5269\u9918" + day + "\u5929\u3002";
		} else {
			return "'" + type + "' has " + day + " day(s) left.";
		}
	}

	public String pendingCount(int day) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "---" + day + "\u5929\u6709\u5F85\u7533\u8BF7\u4E2D\u3002";
		} else if (lang.equals("zh_tw")) {
			return "---" + day + "\u5929\u6709\u5F85\u7533\u8ACB\u4E2D\u3002";
		} else {
			return "---" + day + " day(s) pending.";
		}
	}

	public String approveCount(int day) {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "---" + day + "\u5929\u5DF2\u540C\u610F\u3002<br />";
		} else if (lang.equals("zh_tw")) {
			return "---" + day + "\u5929\u5DF2\u540C\u610F\u3002<br />";
		} else {
			return "---" + day + " day(s) approved.<br />";
		}
	}

	public String peroidError() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u7533\u8BF7\u5931\u8D25\uFF0C\u65E5\u671F\u8303\u56F4\u6709\u8BEF\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u7533\u8ACB\u5931\u6557\uFF0C\u65E5\u671F\u7BC4\u570D\u6709\u8AA4\u3002";
		} else {
			return "Failed, date period is not correct.";
		}
	}

	public String leaveStaus() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u5047\u671F\u6570\u636E<br />";
		} else if (lang.equals("zh_tw")) {
			return "\u5047\u671F\u6578\u64DA<br />";
		} else {
			return " Leave Status<br />";
		}
	}

	public String cr() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u53D6\u6D88\u7533\u8BF7\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u53D6\u6D88\u7533\u8ACB\u55CE\uFF1F";
		} else {
			return "Really want to cancel the request?";
		}
	}

	public String cla() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u53D6\u6D88\u5047\u671F\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u53D6\u6D88\u5047\u671F\u55CE\uFF1F";
		} else {
			return "Really want to cancel the leave approval?";
		}
	}

	public String uc() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u771F\u7684\u8981\u653E\u5F03\u53D6\u6D88\u5417\uFF1F";
		} else if (lang.equals("zh_tw")) {
			return "\u771F\u7684\u8981\u653E\u68C4\u53D6\u6D88\u55CE\uFF1F";
		} else {
			return "Really want to undo cancel?";
		}
	}

	public String cancelRequest() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u53D6\u6D88\u7533\u8BF7";
		} else if (lang.equals("zh_tw")) {
			return "\u53D6\u6D88\u7533\u8ACB";
		} else {
			return "Cancel Request";
		}
	}

	public String cancelLeave() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u53D6\u6D88\u5047\u671F";
		} else if (lang.equals("zh_tw")) {
			return "\u53D6\u6D88\u5047\u671F";
		} else {
			return "Cancel Leave";
		}
	}

	public String undoCancel() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u653E\u5F03\u53D6\u6D88";
		} else if (lang.equals("zh_tw")) {
			return "\u653E\u68C4\u53D6\u6D88";
		} else {
			return "Undo Cancel";
		}
	}

	public String createError() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u7533\u8BF7\u5047\u671F\u5931\u8D25\uFF0C\u65E5\u671F\u8303\u56F4\u5DF2\u5B58\u5728\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u7533\u8ACB\u5047\u671F\u5931\u6557\uFF0C\u65E5\u671F\u7BC4\u570D\u5DF2\u5B58\u5728\u3002";
		} else {
			return "Create failed. The leave period is include in another leave.";
		}
	}

	public String notEnough() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u7533\u8BF7\u5047\u671F\u5931\u8D25\uFF0C\u65E5\u671F\u5269\u4F59\u4E0D\u8DB3\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u7533\u8ACB\u5047\u671F\u5931\u6557\uFF0C\u65E5\u671F\u5269\u9918\u4E0D\u8DB3\u3002";
		} else {
			return "Create failed. The day left is not enough.";
		}
	}

	public String leaveSuccess() {
		String lang = getLang();
		if (lang.equals("zh_cn")) {
			return "\u7533\u8BF7\u5047\u671F\u6210\u529F\u3002";
		} else if (lang.equals("zh_tw")) {
			return "\u7533\u8ACB\u5047\u671F\u6210\u529F\u3002";
		} else {
			return "Create leave success.";
		}
	}

}
